﻿#pragma once

#include "../../../Server/MirEnvir/Envir.h"
#include <string>
#include <vector>
#include <any>
#include "../../../stringhelper.h"

using namespace Microsoft::VisualBasic::PowerPacks;
using namespace Server::MirForms::VisualMapInfo::Class;
using namespace Server::MirEnvir;
using namespace Server::MirDatabase;

namespace Server::MirForms::VisualMapInfo::Control
{
    class RespawnEntry : public UserControl
    {
    public:
        std::vector<int> IndexList = std::vector<int>();

        virtual ~RespawnEntry()
        {
            delete RegionHighlight;
            delete MouseDownLocation;
            delete components;
            delete MonsterComboBox;
            delete Details;
            delete Selected;
            delete Count;
            delete Delay;
        }

        Server::MirEnvir::Envir *getEnvir() const;

        RectangleShape *RegionHighlight = new RectangleShape();

        int MonsterIndex = 0;

        bool RegionHidden = false;

    private:
        Point *MouseDownLocation;

    public:
        int X = 0, Y = 0;

        unsigned char Direction = 0;

        unsigned short RandomDelay = 0;

        unsigned short tempRange = 0;
        unsigned short getRange() const;
        void setRange(unsigned short value);

        std::string RoutePath = std::string::Empty;

        RespawnEntry();

    private:
        void InitializeRegionHighlight();

        #pragma region "Start RegionHighlight Methods"

        void Region_MouseLeave(std::any sender, EventArgs *e);

        void Region_MouseEnter(std::any sender, EventArgs *e);

        void Region_MouseDown(std::any sender, MouseEventArgs *e);

        void Region_MouseMove(std::any sender, MouseEventArgs *e);

        void RegionHighlight_MouseClick(std::any sender, MouseEventArgs *e);

        void RegionHighlight_MouseHover(std::any sender, EventArgs *e);

        #pragma endregion "End RegionHighlight Methods"

    public:
        void UpdateForFocus();

        void RemoveEntry();

        void HideControl();

        void ShowControl();

        void HideRegion();

        void ShowRegion();

    private:
        void RespawnEntry_Load(std::any sender, EventArgs *e);

        void MonsterComboBox_SelectedIndexChanged(std::any sender, EventArgs *e);

        void Details_DoubleClick(std::any sender, EventArgs *e);


        /// <summary> 
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::IContainer *components = nullptr;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected:
        void Dispose(bool disposing) override;

        #pragma region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
    private:
        void InitializeComponent();

        #pragma endregion

        System::Windows::Forms::ComboBox *MonsterComboBox;
        System::Windows::Forms::Label *Details;
    public:
        System::Windows::Forms::CheckBox *Selected;
        System::Windows::Forms::TextBox *Count;
        System::Windows::Forms::TextBox *Delay;
    };
}
